namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmPBTTSPEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblDesc_EN;
        private LabelControl lblDien_Giai;
        private LabelControl lblLay_DL_TH;
        private LabelControl lblLay_DL_TH0;
        private LabelControl lblMa_Sp;
        private LabelControl lblMa_Yt;
        private DmPBSPDataAccess oMethod;
        private TextControl txtDesc_EN;
        private TextControl txtDien_Giai;
        private TextOption txtLay_DL_TH;
        private TextSearch txtMa_Sp;
        private TextSearch txtMa_Yt;
        private TextControl txtTen_Sp;
        private TextControl txtTen_Yt;

        public FormDmPBTTSPEditor()
        {
            this.oMethod = new DmPBSPDataAccess();
            this.InitializeComponent();
        }

        public FormDmPBTTSPEditor(object poUserDefined1, object poUserDefined2, object poUserDefined3, object poUserDefined4) : base(poUserDefined1, poUserDefined2, poUserDefined3, poUserDefined4)
        {
            this.oMethod = new DmPBSPDataAccess();
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormDmPBTTSPEditor));
            this.txtMa_Sp = new QMVnSoft.Controls.TextSearch();
            this.txtTen_Sp = new QMVnSoft.Controls.TextControl();
            this.lblMa_Yt = new QMVnSoft.Controls.LabelControl();
            this.txtTen_Yt = new QMVnSoft.Controls.TextControl();
            this.txtMa_Yt = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Sp = new QMVnSoft.Controls.LabelControl();
            this.lblDesc_EN = new QMVnSoft.Controls.LabelControl();
            this.lblDien_Giai = new QMVnSoft.Controls.LabelControl();
            this.txtDesc_EN = new QMVnSoft.Controls.TextControl();
            this.txtDien_Giai = new QMVnSoft.Controls.TextControl();
            this.lblLay_DL_TH0 = new QMVnSoft.Controls.LabelControl();
            this.txtLay_DL_TH = new QMVnSoft.Controls.TextOption();
            this.lblLay_DL_TH = new QMVnSoft.Controls.LabelControl();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 148);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.Location = new System.Drawing.Point(123, 145);
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.Location = new System.Drawing.Point(251, 145);
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.Location = new System.Drawing.Point(379, 145);
            // 
            // txtMa_Sp
            // 
            this.txtMa_Sp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Sp.CheckTextSearched = false;
            this.txtMa_Sp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Sp.EmptyIsValid = true;
            this.txtMa_Sp.FieldDisplay = "Ten_Sp";
            this.txtMa_Sp.FirstFilter = "SP_CT = \'S\' AND Loai_Sp = \'K\'";
            this.txtMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Sp.FoundIsValid = true;
            this.txtMa_Sp.Location = new System.Drawing.Point(97, 49);
            this.txtMa_Sp.MaxLength = 32;
            this.txtMa_Sp.Name = "txtMa_Sp";
            this.txtMa_Sp.OldValue = null;
            this.txtMa_Sp.Size = new System.Drawing.Size(111, 20);
            this.txtMa_Sp.TabIndex = 1;
            this.txtMa_Sp.TableName = "DMSP";
            this.txtMa_Sp.TextDisplay = this.txtTen_Sp;
            this.txtMa_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Sp.Value = ((object)(resources.GetObject("txtMa_Sp.Value")));
            // 
            // txtTen_Sp
            // 
            this.txtTen_Sp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Sp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Sp.CheckTextSearched = false;
            this.txtTen_Sp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Enabled = false;
            this.txtTen_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Sp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Sp.Location = new System.Drawing.Point(214, 52);
            this.txtTen_Sp.Name = "txtTen_Sp";
            this.txtTen_Sp.OldValue = null;
            this.txtTen_Sp.Size = new System.Drawing.Size(326, 13);
            this.txtTen_Sp.TabIndex = 86;
            this.txtTen_Sp.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Sp.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Sp.Value = ((object)(resources.GetObject("txtTen_Sp.Value")));
            // 
            // lblMa_Yt
            // 
            this.lblMa_Yt.AutoSize = true;
            this.lblMa_Yt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Yt.Location = new System.Drawing.Point(9, 31);
            this.lblMa_Yt.Name = "lblMa_Yt";
            this.lblMa_Yt.Size = new System.Drawing.Size(39, 14);
            this.lblMa_Yt.TabIndex = 83;
            this.lblMa_Yt.Text = "Yếu tố";
            // 
            // txtTen_Yt
            // 
            this.txtTen_Yt.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Yt.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Yt.CheckTextSearched = false;
            this.txtTen_Yt.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Yt.Enabled = false;
            this.txtTen_Yt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Yt.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Yt.Location = new System.Drawing.Point(214, 31);
            this.txtTen_Yt.Name = "txtTen_Yt";
            this.txtTen_Yt.OldValue = null;
            this.txtTen_Yt.Size = new System.Drawing.Size(326, 13);
            this.txtTen_Yt.TabIndex = 85;
            this.txtTen_Yt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Yt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Yt.Value = ((object)(resources.GetObject("txtTen_Yt.Value")));
            // 
            // txtMa_Yt
            // 
            this.txtMa_Yt.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Yt.CheckTextSearched = false;
            this.txtMa_Yt.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Yt.FieldDisplay = "Ten_Yt";
            this.txtMa_Yt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Yt.Location = new System.Drawing.Point(97, 28);
            this.txtMa_Yt.MaxLength = 32;
            this.txtMa_Yt.Name = "txtMa_Yt";
            this.txtMa_Yt.OldValue = null;
            this.txtMa_Yt.Size = new System.Drawing.Size(111, 20);
            this.txtMa_Yt.TabIndex = 0;
            this.txtMa_Yt.TableName = "DMYT";
            this.txtMa_Yt.TextDisplay = this.txtTen_Yt;
            this.txtMa_Yt.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Yt.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Yt.Value = ((object)(resources.GetObject("txtMa_Yt.Value")));
            // 
            // lblMa_Sp
            // 
            this.lblMa_Sp.AutoSize = true;
            this.lblMa_Sp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Sp.Location = new System.Drawing.Point(9, 52);
            this.lblMa_Sp.Name = "lblMa_Sp";
            this.lblMa_Sp.Size = new System.Drawing.Size(59, 14);
            this.lblMa_Sp.TabIndex = 84;
            this.lblMa_Sp.Text = "Công đoạn";
            // 
            // lblDesc_EN
            // 
            this.lblDesc_EN.AutoSize = true;
            this.lblDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDesc_EN.Location = new System.Drawing.Point(9, 94);
            this.lblDesc_EN.Name = "lblDesc_EN";
            this.lblDesc_EN.Size = new System.Drawing.Size(71, 14);
            this.lblDesc_EN.TabIndex = 89;
            this.lblDesc_EN.Text = "Diễn giải (EN)";
            // 
            // lblDien_Giai
            // 
            this.lblDien_Giai.AutoSize = true;
            this.lblDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDien_Giai.Location = new System.Drawing.Point(9, 73);
            this.lblDien_Giai.Name = "lblDien_Giai";
            this.lblDien_Giai.Size = new System.Drawing.Size(73, 14);
            this.lblDien_Giai.TabIndex = 90;
            this.lblDien_Giai.Text = "Diễn giải (VN)";
            // 
            // txtDesc_EN
            // 
            this.txtDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDesc_EN.CheckTextSearched = false;
            this.txtDesc_EN.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDesc_EN.Location = new System.Drawing.Point(97, 91);
            this.txtDesc_EN.MaxLength = 128;
            this.txtDesc_EN.Name = "txtDesc_EN";
            this.txtDesc_EN.OldValue = null;
            this.txtDesc_EN.Size = new System.Drawing.Size(443, 20);
            this.txtDesc_EN.TabIndex = 3;
            this.txtDesc_EN.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtDesc_EN.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtDesc_EN.Value = ((object)(resources.GetObject("txtDesc_EN.Value")));
            // 
            // txtDien_Giai
            // 
            this.txtDien_Giai.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDien_Giai.CheckTextSearched = false;
            this.txtDien_Giai.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDien_Giai.Location = new System.Drawing.Point(97, 70);
            this.txtDien_Giai.MaxLength = 128;
            this.txtDien_Giai.Name = "txtDien_Giai";
            this.txtDien_Giai.OldValue = null;
            this.txtDien_Giai.Size = new System.Drawing.Size(443, 20);
            this.txtDien_Giai.TabIndex = 2;
            this.txtDien_Giai.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.ItemDescription;
            this.txtDien_Giai.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtDien_Giai.Value = ((object)(resources.GetObject("txtDien_Giai.Value")));
            // 
            // lblLay_DL_TH0
            // 
            this.lblLay_DL_TH0.AutoSize = true;
            this.lblLay_DL_TH0.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblLay_DL_TH0.ForeColor = System.Drawing.Color.Blue;
            this.lblLay_DL_TH0.Location = new System.Drawing.Point(126, 115);
            this.lblLay_DL_TH0.Name = "lblLay_DL_TH0";
            this.lblLay_DL_TH0.Size = new System.Drawing.Size(215, 14);
            this.lblLay_DL_TH0.TabIndex = 93;
            this.lblLay_DL_TH0.Text = "0-Từ phân bổ chung, 1-Từ phát sinh chi tiết";
            // 
            // txtLay_DL_TH
            // 
            this.txtLay_DL_TH.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtLay_DL_TH.CheckTextSearched = false;
            this.txtLay_DL_TH.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtLay_DL_TH.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtLay_DL_TH.InputMask = "1,0";
            this.txtLay_DL_TH.Location = new System.Drawing.Point(97, 112);
            this.txtLay_DL_TH.Name = "txtLay_DL_TH";
            this.txtLay_DL_TH.OldValue = null;
            this.txtLay_DL_TH.Size = new System.Drawing.Size(23, 20);
            this.txtLay_DL_TH.TabIndex = 4;
            this.txtLay_DL_TH.Text = "1";
            this.txtLay_DL_TH.UserTextLength  = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtLay_DL_TH.UserTrimMode  = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtLay_DL_TH.Value = "1";
            // 
            // lblLay_DL_TH
            // 
            this.lblLay_DL_TH.AutoSize = true;
            this.lblLay_DL_TH.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblLay_DL_TH.Location = new System.Drawing.Point(9, 115);
            this.lblLay_DL_TH.Name = "lblLay_DL_TH";
            this.lblLay_DL_TH.Size = new System.Drawing.Size(84, 14);
            this.lblLay_DL_TH.TabIndex = 91;
            this.lblLay_DL_TH.Text = "Cách lấy dữ liệu";
            // 
            // FormDmPBTTSPEditor
            // 
            this.AddTitleText = "Thêm bút toán phân bổ sản phẩm trực tiếp";
            this.ClientSize = new System.Drawing.Size(552, 179);
            this.Controls.Add(this.lblLay_DL_TH0);
            this.Controls.Add(this.txtLay_DL_TH);
            this.Controls.Add(this.lblLay_DL_TH);
            this.Controls.Add(this.lblDesc_EN);
            this.Controls.Add(this.lblDien_Giai);
            this.Controls.Add(this.txtDesc_EN);
            this.Controls.Add(this.txtDien_Giai);
            this.Controls.Add(this.txtMa_Sp);
            this.Controls.Add(this.lblMa_Yt);
            this.Controls.Add(this.txtTen_Yt);
            this.Controls.Add(this.txtTen_Sp);
            this.Controls.Add(this.txtMa_Yt);
            this.Controls.Add(this.lblMa_Sp);
            this.EditTitleText = "Sửa bút toán phân bổ sản phẩm trực tiếp";
            this.Name = "FormDmPBTTSPEditor";
            this.ShowFreeFields = false;
            this.Text = "Thêm bút toán phân bổ sản phẩm trực tiếp";
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.lblMa_Sp, 0);
            this.Controls.SetChildIndex(this.txtMa_Yt, 0);
            this.Controls.SetChildIndex(this.txtTen_Sp, 0);
            this.Controls.SetChildIndex(this.txtTen_Yt, 0);
            this.Controls.SetChildIndex(this.lblMa_Yt, 0);
            this.Controls.SetChildIndex(this.txtMa_Sp, 0);
            this.Controls.SetChildIndex(this.txtDien_Giai, 0);
            this.Controls.SetChildIndex(this.txtDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblDien_Giai, 0);
            this.Controls.SetChildIndex(this.lblDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblLay_DL_TH, 0);
            this.Controls.SetChildIndex(this.txtLay_DL_TH, 0);
            this.Controls.SetChildIndex(this.lblLay_DL_TH0, 0);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_Yt.Text))
            {
                MessageBox.Show("Chưa nhập mã yếu tố!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Dvcs"] = AppInstance.Subsidiary;
            localCurrentRow["Ma_Yt"] = this.txtMa_Yt.Value;
            localCurrentRow["Ten_Yt"] = this.txtTen_Yt.Value;
            localCurrentRow["Ma_Sp"] = this.txtMa_Sp.Value;
            localCurrentRow["Ten_Sp"] = this.txtTen_Sp.Value;
            localCurrentRow["Dien_Giai"] = this.txtDien_Giai.Value;
            localCurrentRow["Desc_EN"] = this.txtDesc_EN.Value;
            localCurrentRow["Lay_DL_TH"] = this.txtLay_DL_TH.Value;
            localCurrentRow["Loai_Pb"] = base.UserDefined4;
            localCurrentRow["Loai_Yt"] = "L";
            localCurrentRow["SLuong_Ck"] = "K";
            if (this.oMethod.SaveRow(base.NewChecked, localCurrentRow) != 1)
            {
                MessageBox.Show("Không lưu được dữ liệu!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Yt.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Yt.Value = base.LocalCurrentRow["Ma_Yt"];
            this.txtTen_Yt.Value = base.LocalCurrentRow["Ten_Yt"];
            this.txtMa_Sp.Value = base.LocalCurrentRow["Ma_Sp"];
            this.txtTen_Sp.Value = base.LocalCurrentRow["Ten_Sp"];
            this.txtDien_Giai.Value = base.LocalCurrentRow["Dien_Giai"];
            this.txtDesc_EN.Value = base.LocalCurrentRow["Desc_EN"];
            this.txtLay_DL_TH.Value = base.LocalCurrentRow["Lay_DL_TH"];
            base.OnShow();
        }
    }
}

